﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="SysUserEdit.aspx.cs" Inherits="CXedu.WebSite.WebAdmin.SysUserEdit" %>
<%@ Import Namespace="System.Linq" %>
<%@ Import Namespace="CXedu.Model" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title><%=id > 0 ? (type == "2" ? "修改密码" : "修改权限") : "新建用户"%></title>
    <link href="/css/admin/admin.css" type="text/css" rel="stylesheet" />
    <script type="text/javascript" src="/js/jquery.js"></script>
    <script type="text/javascript" src="/js/admin/admin.js"></script>
</head>
<body>
    <div class="titlebt"><%=id > 0 ? (type == "2" ? "修改密码" : "修改权限") : "新建用户"%></div>
    <!--显示列表-->
    <div id="all">
        <div class="k_all3">
            <form action="" method="post" onsubmit="return checkdata()">
            <table width="100%" cellpadding="0" cellspacing="0" id="bk">
                <tbody>
                    <% 
                        if (type == "1")      //新建用户
                        {
                    %>
                    <tr>
                        <td width="326" height="35" align="right">
                            <span class="red">*</span>用户登录名：
                        </td>
                        <td width="990">
                            <input type="text" id="username" name="username" value="" data-val="true" data-val-required="*用户登录名是必填项！"/>
                            <span class="field-validation-valid" data-valmsg-for="username" data-valmsg-replace="true"></span>
                        </td>
                    </tr>
                    <tr>
                        <td width="326" height="35" align="right">
                            <span class="red">*</span>用户昵称：
                        </td>
                        <td width="990">
                            <input type="text" id="realname" name="realname" value="" data-val="true" data-val-required="*用户昵称是必填项！"/>
                            <span class="field-validation-valid" data-valmsg-for="realname" data-valmsg-replace="true"></span>
                        </td>
                    </tr>
                    <tr>
                        <td width="326" height="35" align="right">
                            <span class="red">*</span>登录密码：
                        </td>
                        <td width="990">
                            <input type="password" id="password" name="password" value="" data-val="true" data-val-required="*登录密码是必填项！" data-val-length-min="6" data-val-length-max="20" data-val-length="*密码需要在6-20位之间！"/>
                            <span class="field-validation-valid" data-valmsg-for="password" data-valmsg-replace="true"></span>
                        </td>
                    </tr>
                    <tr>
                        <td width="326" height="35" align="right">
                            <span class="red">*</span>确认登录密码：
                        </td>
                        <td width="990">
                            <input type="password" id="dpassword" name="dpassword" value="" data-val="true" data-val-required="*确认登录密码是必填项！" data-val-length-min="6" data-val-length-max="20" data-val-length="*密码需要在6-20位之间！" />
                            <span class="field-validation-valid" data-valmsg-for="dpassword" data-valmsg-replace="true"></span>
                        </td>
                    </tr>
                    <%
                        }
                        else if (type == "2") //修改密码
                        {
                    %>
                    <tr>
                        <td width="326" height="35" align="right">
                            用户登录名：
                        </td>
                        <td width="990">
                            <%=userInfo.Name%>
                        </td>
                    </tr>
                    <tr>
                        <td width="326" height="35" align="right">
                            <span class="red">*</span>老密码：
                        </td>
                        <td width="990">
                            <input type="password" id="oldpassword" name="oldpassword" value=""  data-val="true" data-val-required="*老密码是必填项！" data-val-length-min="6" data-val-length-max="20" data-val-length="*密码需要在6-20位之间！"/>
                            <span class="field-validation-valid" data-valmsg-for="oldpassword" data-valmsg-replace="true"></span>
                        </td>
                    </tr>
                    <tr>
                        <td width="326" height="35" align="right">
                            <span class="red">*</span>新密码：
                        </td>
                        <td width="990">
                            <input type="password" id="newpassword" name="newpassword" value=""  data-val="true" data-val-required="*新密码是必填项！" data-val-length-min="6" data-val-length-max="20" data-val-length="*密码需要在6-20位之间！"/>
                            <span class="field-validation-valid" data-valmsg-for="newpassword" data-valmsg-replace="true"></span>
                        </td>
                    </tr>
                    <tr>
                        <td width="326" height="35" align="right">
                            <span class="red">*</span>确认新密码：
                        </td>
                        <td width="990">
                            <input type="password" id="dnewpassword" name="dnewpassword" value=""  data-val="true" data-val-required="*确认新密码是必填项！" data-val-length-min="6" data-val-length-max="20" data-val-length="*密码需要在6-20位之间！"/>
                            <span class="field-validation-valid" data-valmsg-for="dnewpassword" data-valmsg-replace="true"></span>
                        </td>
                    </tr>
                    <%
                        }
                        if (type != "2") 
                        {
                            if (type == "3")//修改权限
                            {
                    %>
                    <tr>
                        <td width="326" height="35" align="right">
                            用户登录名：
                        </td>
                        <td width="990">
                            <%=userInfo.Name%>
                        </td>
                    </tr>
                    <tr>
                        <td width="326" height="35" align="right">
                            <span class="red">*</span>用户昵称：
                        </td>
                        <td width="990">
                            <input type="text" id="uprealname" name="uprealname" value="<%=userInfo.RealName%>" data-val="true" data-val-required="*用户昵称是必填项！"/>
                            <span class="field-validation-valid" data-valmsg-for="uprealname" data-valmsg-replace="true"></span>
                        </td>
                    </tr>
                    <%                                  
                            }
                    %>
                    <tr>
                        <td width="326" height="35" align="right">
                            模块权限：
                        </td>
                        <td width="990">
                            <% 
               
                                foreach (SysModule module in sysModuleList.Where(m => m.PId == "" || m.PId == "0"))
                                {
                             %>
                             <p><b><%=module.Name%></b></p>
                             &nbsp;&nbsp;&nbsp;&nbsp;
                             <%
                                    foreach (SysModule item in sysModuleList.Where(m => m.PId == module.Id))
                                    {
                                        string check = ((userInfo.ModuleIds + ",").IndexOf(item.Id.ToString() + ",") >= 0) ? "checked=\"checked\"" : "";
                            %>
                            <input type="checkbox" id="ckModuleid<%=item.Id%>" name="ckModuleid" value="<%=item.Id%>" <%=check %>
                            /><label for="ckModuleid<%=item.Id%>"><%=item.Name%></label>
                            <%
                                    }
                                }
                            %>
                        </td>
                    </tr>
                    <%
                        }
                    %>
                    <tr>
                        <td colspan="2" height="35">
                            <div class="pl200">
                                <input type="submit" class="butt_tle" style="width: 50px" value="确定" />
                                <input type="button" class="butt_tle" style="width: 80px" value="返回列表" onclick='location.href="SysUsers.aspx"'/>
                            </div>
                        </td>
                    </tr>
                </tbody>
            </table>
            </form>
        </div>
    </div>
    <script type="text/javascript">
        function checkdata() {
            if ($("#password").val() != $("#dpassword").val()) {
                var obj = $("span[data-valmsg-for=\"dpassword\"]");
                obj.addClass("field-validation-error").removeClass("field-validation-valid").html("*两次密码必须一致！").show();
                return false;
            }
            return true;
        }
    </script>
</body>
</html>